<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@include file="../include/taglibs.jsp"%>

<fmt:message key="home.allGames" var="allGames" scope="page"/>
<fmt:message key="home.newGame" var="newGame" scope="page"/>
<fmt:message key="home.title" var="titleLabel" scope="page"/>
<fmt:message key="home.size" var="sizeLabel" scope="page"/>
<fmt:message key="home.description" var="descriptionLabel" scope="page"/>
<fmt:message key="home.next" var="next" scope="page"/>

<c:url var="buzzwordsUrl" value="/buzzwords" />

<div class="divTable" style="width:100%;">

<div>
<div style="width:100%">
<h3>${allGames}</h3>
<div id="games">
<table style="width:100%">
	<tr>
	<th style="text-align:left;">Titel</th>
	<th style="text-align:left;">Ersteller</th>
	<th style="text-align:left; white-space:nowrap;">Beginn</th>
	</tr>	
	<c:forEach var="game" items="${games}">
		<c:if test="${game.winner == null}">
		<tr>
		<c:url var="gameUrl" value="/game/${game.id}" />
		<td><a href="${gameUrl}">${game.id}</a></td>
		<td>${game.owner.name}</td>
		<td><fmt:formatDate value="${game.creationTimeDate}" pattern="yyyy-MM-dd hh:mm:ss" /></td>
		</tr>
		
		
		</c:if>
	</c:forEach>
</table>
</div>

</div>
<div>

<h3>${newGame}</h3>	
<form class="divTable" method="post" action="${buzzwordsUrl}">	
	<div>
		<div>${titleLabel}</div>
		<div><input type="text" name="title" style="width:300px;" value="${fn:escapeXml(title)}" /></div>
		<div>
			<c:if test="${titleError}">
				<fmt:message key="${titleErrorMsg}" />
			</c:if>
		</div>
	</div>
	<div>
		<div>${sizeLabel}</div>
		<div>
			<select name="size">
				<c:forEach var="i" begin="${minGameSize}" end="${maxGameSize}">
				<option value="${i}">${i}</option>
				</c:forEach>
			</select>
		</div>
		<div>
			<c:if test="${sizeError}">
				<fmt:message key="${sizeErrorMsg}" />
			</c:if>
		</div>
	</div>
		<div>
		<div>${descriptionLabel}</div>
		<div><textarea name="description" rows="4" style="width:300px;">${fn:escapeXml(description)}</textarea></div>
	</div>
	<div><div></div>
	<div style="text-align:right">
	<input type="submit" value="${next}"/>
	</div>
	</div>
</form>

</div>
</div>
</div>

<script type="text/javascript">
</script>